curr = input()
n = int(input())
for k in range(n):
    next_floor = []
    slow = 0
    fast = 0
    while fast < len(curr):
        if curr[fast] != curr[slow]:
            next_floor.append(str(fast - slow))
            next_floor.append(curr[slow])
            slow = fast
        else:
            fast += 1
    if slow != fast:
        next_floor.append(str(fast - slow))
        next_floor.append(curr[slow])
    curr = next_floor
print("".join(curr))
